package ihm_clarifiee.Presentation;
import ihm_clarifiee.Control.*;
import javax.swing.*;

public class PTache extends javax.swing.JPanel{

	private CTache controle;
	private JTextField tf_titre;
	private JTextField tf_desc;
	private JTextField tf_duree;
	private JLabel lb_titre;
	private JLabel lb_desc;
	private JLabel lb_duree;
	

	public PTache(CTache c){
		controle = c;
		initComponents();
	}
	
	public CTache getControle(){
		return controle;
	}
	
	public void setControle(CTache c){
		controle = c;
	}
	
	private void initComponents(){
		
		this.setSize(750,500);
		
        tf_titre = new javax.swing.JTextField();
        tf_desc = new javax.swing.JTextField();
        tf_duree = new javax.swing.JTextField();
        lb_titre = new javax.swing.JLabel();
        lb_desc = new javax.swing.JLabel();
        lb_duree = new javax.swing.JLabel();

     
        tf_titre.setText(controle.getTitre());

        tf_desc.setText(controle.getDescription());

        tf_duree.setText(""+controle.getDuree());

        lb_titre.setText("Titre");

        lb_desc.setText("Description");

        lb_duree.setText("Duree");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tf_titre, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_titre))
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tf_desc, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_desc))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tf_duree, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_duree))
                .addContainerGap(32, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_titre)
                    .addComponent(lb_desc)
                    .addComponent(lb_duree))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tf_titre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_desc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_duree, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(249, Short.MAX_VALUE))
        );
	}
	
	public void update(){
		controle.setTitre(tf_titre.getText());
		controle.setDescription(tf_desc.getText());
		controle.setDuree(Integer.valueOf(tf_duree.getText()));
	}
	
}
